/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.expression;

import java.util.List;

import org.springframework.lang.Nullable;

/**
 * 表达式在计算上下文中执行。
 * 在表达式计算期间遇到引用时，正是在这种上下文中解析引用。它的默认实现为：StandardEvaluationContext
 *
 * @author Andy Clement
 * @author Juergen Hoeller
 * @since 3.0
 */
public interface EvaluationContext {

	/**
	 * 上下文可议持有一个根对象~~
	 */
	TypedValue getRootObject( );

	// 返回属性访问器列表，这些访问器将依次被要求读取/写入属性  注意此处的属性访问器是el包自己的，不是bean包下的~~~
	// ReflectivePropertyAccessor（DataBindingPropertyAccessor）：通过反射读/写对象的属性~
	// BeanFactoryAccessor：这个属性访问器让支持bean从bean工厂里获取
	// EnvironmentAccessor：可以从环境中.getProperty(name)
	// BeanExpressionContextAccessor：和BeanExpressionContext相关
	// MapAccessor：可以从map中获取值~~~
	List<PropertyAccessor> getPropertyAccessors( );

	// ConstructorResolver它只有一个实现：ReflectiveConstructorResolver
	List<ConstructorResolver> getConstructorResolvers( );

	// 它的实现：ReflectiveMethodResolver/DataBindingMethodResolver
	List<MethodResolver> getMethodResolvers( );

	// 返回一个处理器：它能够通过beanName找到bean
	// BeanResolver：唯一实现 BeanFactoryResolver  它内部持有BeanFactory的引用~  return this.beanFactory.getBean(beanName);
	@Nullable
	BeanResolver getBeanResolver( );

	// 返回一个类型定位器，该定位器可用于通过短名称或完全限定名称查找类型 唯一实现：StandardTypeLocator

	TypeLocator getTypeLocator( );

	// TypeConverter：唯一实现为StandardTypeConverter  其实还是依赖DefaultConversionService的
	TypeConverter getTypeConverter( );

	/**
	 * Return a type comparator for comparing pairs of objects for equality.
	 */
	TypeComparator getTypeComparator( );

	// 处理重载的
	OperatorOverloader getOperatorOverloader( );

	// 这两个方法，就是在这个上下文里设置值、查找值的~~~~
	void setVariable(String name, @Nullable Object value);

	@Nullable
	Object lookupVariable(String name);

}
